home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / string / nsTObsoleteAString.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  7KB  |  166 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* vim:set ts=2 sw=2 sts=2 et cindent: */
  3. /* ***** BEGIN LICENSE BLOCK *****
  4.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.  *
  6.  * The contents of this file are subject to the Mozilla Public License Version
  7.  * 1.1 (the "License"); you may not use this file except in compliance with
  8.  * the License. You may obtain a copy of the License at
  9.  * http://www.mozilla.org/MPL/
  10.  *
  11.  * Software distributed under the License is distributed on an "AS IS" basis,
  12.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.  * for the specific language governing rights and limitations under the
  14.  * License.
  15.  *
  16.  * The Original Code is Mozilla.
  17.  *
  18.  * The Initial Developer of the Original Code is IBM Corporation.
  19.  * Portions created by IBM Corporation are Copyright (C) 2003
  20.  * IBM Corporation. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Darin Fisher <darin@meer.net>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  27.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39.  
  40.   /**
  41.    * nsTObsoleteAString_CharT : binary compatible with old nsAC?String vtable
  42.    *
  43.    * @status FROZEN
  44.    */
  45. class nsTObsoleteAString_CharT
  46.   {
  47.     public:
  48.       /**
  49.        * This is holds the address of the vtable for the canonical string
  50.        * implementation (i.e., nsTString).
  51.        */
  52.       NS_COM static const void *sCanonicalVTable;
  53.  
  54.         /**
  55.          * An |nsFragmentRequest| is used to tell |GetReadableFragment| and
  56.          * |GetWritableFragment| what to do.
  57.          *
  58.          * @see GetReadableFragment
  59.          */
  60.       enum nsFragmentRequest { kPrevFragment, kFirstFragment, kLastFragment, kNextFragment, kFragmentAt };
  61.  
  62.         /**
  63.          * A |nsReadableFragment| provides |const| access to a contiguous hunk of
  64.          * string of homogenous units, e.g., bytes (|char|).  This doesn't mean it
  65.          * represents a flat hunk.  It could be a variable length encoding, for
  66.          * instance UTF-8.  And the fragment itself need not be zero-terminated.
  67.          *
  68.          * An |nsReadableFragment| is the underlying machinery that lets
  69.          * |nsReadingIterator|s work.
  70.          *
  71.          * @see nsReadingIterator
  72.          * @status FROZEN
  73.          */
  74.       struct nsReadableFragment
  75.         {
  76.           const CharT*  mStart;
  77.           const CharT*  mEnd;
  78.           const void*   mFragmentIdentifier;
  79.  
  80.           nsReadableFragment() : mStart(0), mEnd(0), mFragmentIdentifier(0) {}
  81.         };
  82.  
  83.  
  84.         /**
  85.          * A |nsWritableFragment| provides non-|const| access to a contiguous hunk of
  86.          * string of homogenous units, e.g., bytes (|char|).  This doesn't mean it
  87.          * represents a flat hunk.  It could be a variable length encoding, for
  88.          * instance UTF-8.  And the fragment itself need not be zero-terminated.
  89.          *
  90.          * An |nsWritableFragment| is the underlying machinery that lets
  91.          * |nsWritingIterator|s work.
  92.          *
  93.          * @see nsWritingIterator
  94.          * @status FROZEN
  95.          */
  96.       struct nsWritableFragment
  97.         {
  98.           CharT*    mStart;
  99.           CharT*    mEnd;
  100.           void*     mFragmentIdentifier;
  101.  
  102.           nsWritableFragment() : mStart(0), mEnd(0), mFragmentIdentifier(0) {}
  103.         };
  104.  
  105.     protected:
  106.  
  107.       typedef CharT                                char_type;
  108.  
  109.       typedef void                                 buffer_handle_type;
  110.       typedef void                                 shared_buffer_handle_type;
  111.       typedef nsReadableFragment                   const_fragment_type;
  112.       typedef nsWritableFragment                   fragment_type;
  113.  
  114.       typedef nsTAString_CharT                     abstract_string_type;
  115.  
  116.       typedef PRUint32                             size_type;
  117.       typedef PRUint32                             index_type;
  118.  
  119.     protected:
  120.  
  121.       friend class nsTAString_CharT;
  122.       friend class nsTSubstring_CharT;
  123.  
  124.       /** here's the old nsAC?String vtable **/
  125.  
  126.       virtual ~nsTObsoleteAString_CharT() { }
  127.  
  128.       virtual PRUint32                          GetImplementationFlags() const = 0;
  129.       virtual const        buffer_handle_type*  GetFlatBufferHandle()    const = 0;
  130.       virtual const        buffer_handle_type*  GetBufferHandle()        const = 0;
  131.       virtual const shared_buffer_handle_type*  GetSharedBufferHandle()  const = 0;
  132.  
  133.       virtual size_type Length() const = 0;
  134.  
  135.       virtual PRBool IsVoid() const = 0;
  136.       virtual void SetIsVoid( PRBool ) = 0;
  137.  
  138.       virtual void SetCapacity( size_type ) = 0;
  139.       virtual void SetLength( size_type ) = 0;
  140.  
  141.       virtual void Cut( index_type cutStart, size_type cutLength ) = 0;
  142.  
  143.       virtual void do_AssignFromReadable( const abstract_string_type& ) = 0;
  144.       virtual void do_AssignFromElementPtr( const char_type* ) = 0;
  145.       virtual void do_AssignFromElementPtrLength( const char_type*, size_type ) = 0;
  146.       virtual void do_AssignFromElement( char_type ) = 0;
  147.  
  148.       virtual void do_AppendFromReadable( const abstract_string_type& ) = 0;
  149.       virtual void do_AppendFromElementPtr( const char_type* ) = 0;
  150.       virtual void do_AppendFromElementPtrLength( const char_type*, size_type ) = 0;
  151.       virtual void do_AppendFromElement( char_type ) = 0;
  152.  
  153.       virtual void do_InsertFromReadable( const abstract_string_type&, index_type ) = 0;
  154.       virtual void do_InsertFromElementPtr( const char_type*, index_type ) = 0;
  155.       virtual void do_InsertFromElementPtrLength( const char_type*, index_type, size_type ) = 0;
  156.       virtual void do_InsertFromElement( char_type, index_type ) = 0;
  157.  
  158.       virtual void do_ReplaceFromReadable( index_type, size_type, const abstract_string_type& ) = 0;
  159.  
  160.       virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 = 0 ) const = 0;
  161.       virtual       char_type* GetWritableFragment(       fragment_type&, nsFragmentRequest, PRUint32 = 0 ) = 0;
  162.   };
  163.  
  164.   // forward declare implementation
  165. class nsTObsoleteAStringThunk_CharT;
  166.